package cn.szabadsag.user.controller;

import cn.szabadsag.user.domain.User;
import cn.szabadsag.user.service.IUserService;
import cn.szabadsag.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户表现层
 * @author yangcong
 * @date 2022年03月10日 18:16
 * @since v1.0
 */
@RestController
@RequestMapping("/user")
public class UserController {


    @Autowired
    private IUserService userService;

    /**
     * 校验手机号码
     * @param user 接收前端的数据
     * @return
     */
    @PostMapping("/verifyPhone")
    public AjaxResult verifyPhone(@RequestBody User user){
        //  根据手机号查询对象
        User userInfo = userService.loadByPhone(user.getPhone());
        if (userInfo == null){
            return AjaxResult.me();
        }else {
            return AjaxResult.me().setMessage("手机号已注册!");
        }
    }



}
